package com.own.business.system.user.entity.vo;

import com.own.business.system.user.entity.po.SystemUserInfo;
import com.own.component.common.base.entity.vo.BaseVo;
import com.own.constant.ConstantBeanSuffix;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.NonNull;
import lombok.Setter;
import lombok.ToString;
import lombok.experimental.Accessors;

/**
 * SystemUserInfoVo
 *
 * @author chenxueli
 * @date 2021/06/24 15:46:54
 */
@Schema(title = "系统用户基本信息" + ConstantBeanSuffix.VO)
@Getter
@Setter
@ToString
@Accessors(chain = true)
@AllArgsConstructor
@NoArgsConstructor
public class SystemUserInfoVo extends BaseVo<SystemUserInfo> {

    @Schema(title = "用户id")
    private Long userId;

    @Schema(title = "名称")
    private String name;

    @Schema(title = "手机号")
    private String phone;

    @Schema(title = "邮箱")
    private String email;

    @Schema(title = "性别 1=男 2=女 0=保密")
    private Integer gender;

    @Schema(title = "头像")
    private String avatar;

    @Schema(title = "介绍")
    private String introduction;

    @Schema(title = "用户类型 1=普通用户 2=管理员")
    private Integer type;

    /**
     * 构造方法
     *
     * @param entity 原对象
     */
    public SystemUserInfoVo(@NonNull SystemUserInfo entity) {
        super(entity);
        this.userId = entity.getFkUserId();
        this.name = entity.getName();
        this.phone = entity.getPhone();
        this.email = entity.getEmail();
        this.gender = entity.getGender();
        this.avatar = entity.getAvatar();
        this.introduction = entity.getIntroduction();
        this.type = entity.getType();
    }

    /**
     * 转po对象
     *
     * @param entity 原
     * @return po对象
     */
    @Override
    public SystemUserInfo toPo(SystemUserInfo entity) {
        if (entity == null) {
            entity = new SystemUserInfo();
        }
        entity.setFkUserId(this.userId);
        entity.setName(this.name);
        entity.setPhone(this.phone);
        entity.setEmail(this.email);
        entity.setGender(this.gender);
        entity.setAvatar(this.avatar);
        entity.setIntroduction(this.introduction);
        entity.setType(this.type);
        return super.toPo(entity);
    }

}
